//
//  BodyCheckCheckResultDetailView.m
//  TryShopping
//
//  Created by panquanReabam.com on 16/9/8.
//  Copyright © 2016年 RuiBen. All rights reserved.
//

#import "BodyCheckCheckResultDetailView.h"



@interface BodyCheckCheckResultDetailView()
@property(nonatomic,strong)UILabel *reportNo;
@property(nonatomic,strong)UILabel *serialNumber;
@property(nonatomic,strong)UILabel *reportDate;
@property(nonatomic,strong)UILabel *reportDateName;
@property(nonatomic,strong)UILabel *companyName;
@property(nonatomic,strong)UILabel *address;
@property(nonatomic,strong)UILabel *inspectionRecords;
@property(nonatomic,strong)UILabel *lineLabel;
@end
@implementation BodyCheckCheckResultDetailView
{
    NSMutableArray*imgListImgUrl1;
     NSMutableArray*imgListImgUrl2;
     NSMutableArray*imgListImgUrl3;
}
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        
    }
    return self;
}
#pragma mark InitUI

-(void)jiantouBtn:(UIButton*)sender{
    
    [_mDelegate memberBtn:@""];
}
-(void)setModel:(BodyCheckCheckResultDetailModel *)model{
      imgListImgUrl1=[[NSMutableArray alloc]init];
      imgListImgUrl2=[[NSMutableArray alloc]init];
      imgListImgUrl3=[[NSMutableArray alloc]init];
   [self createView];
    [self setViewAutoLayout];
   
    self.reportNo.text=[NSString stringWithFormat:@"%@",[model.dict objectForKey:@"reportNo"]];
    self.reportDate.text=[NSString stringWithFormat:@"%@",[model.dict objectForKey:@"reportDate"]];

    self.companyName.text=[NSString stringWithFormat:@"%@",[model.dict objectForKey:@"companyName"]];

    if ([[model.dict valueForKey:@"imgList"]count]>0) {
        for (NSDictionary* dicc in [model.dict valueForKey:@"imgList"]  )
        {
            
             [imgListImgUrl1 addObject:[dicc valueForKey:@"imgUrl"]];
        }}
        if ([[model.dict valueForKey:@"imgList2"]count]>0) {
            for (NSDictionary* dicc in [model.dict valueForKey:@"imgList2"]  )
            {
                
                [imgListImgUrl2 addObject:[dicc valueForKey:@"imgUrl"]];
            }}
            if ([[model.dict valueForKey:@"imgList3"]count]>0) {
                for (NSDictionary* dicc in [model.dict valueForKey:@"imgList3"]  )
                {
                    
                    [imgListImgUrl3 addObject:[dicc valueForKey:@"imgUrl"]];
                }}
    
    NSLog(@"%@%@%@",imgListImgUrl1,imgListImgUrl2,imgListImgUrl3);
    
    
    
    
    for (int i = 0; i<imgListImgUrl1.count; i++) {
        UIButton*funNameBtn=[[UIButton alloc]initWithFrame:CGRectMake(10, 152.5+60*i,ScreenWidth/3-10, 55)];
        [funNameBtn setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@",imgListImgUrl1[i]]]];
        [funNameBtn setTitleColor:qianheiColor forState:UIControlStateNormal];
//        [funNameBtn addTarget:self action:@selector(funNameBtn:) forControlEvents:UIControlEventTouchUpInside];
        funNameBtn.titleLabel.font=[UIFont systemFontOfSize:contenfot];
        funNameBtn.contentHorizontalAlignment=UIControlContentHorizontalAlignmentLeft;
        [self addSubview:funNameBtn];

    
    }
    
    for (int i = 0; i<imgListImgUrl2.count; i++) {
        UIButton*funNameBtn=[[UIButton alloc]initWithFrame:CGRectMake(ScreenWidth/3+5, 152.5+60*i, ScreenWidth/3-10, 55)];
        [funNameBtn setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@",imgListImgUrl2[i]]]];
        [funNameBtn setTitleColor:qianheiColor forState:UIControlStateNormal];
//        [funNameBtn addTarget:self action:@selector(funNameBtn:) forControlEvents:UIControlEventTouchUpInside];
        funNameBtn.titleLabel.font=[UIFont systemFontOfSize:contenfot];
        funNameBtn.contentHorizontalAlignment=UIControlContentHorizontalAlignmentLeft;
        [self addSubview:funNameBtn];
        
        
    }

    for (int i = 0; i<imgListImgUrl3.count; i++) {
        UIButton*funNameBtn=[[UIButton alloc]initWithFrame:CGRectMake(ScreenWidth/3*2, 152.5+60*i, ScreenWidth/3-10, 55)];
   
        [funNameBtn setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@",imgListImgUrl3[i]]]];
        [funNameBtn setTitleColor:qianheiColor forState:UIControlStateNormal];
//        [funNameBtn addTarget:self action:@selector(funNameBtn:) forControlEvents:UIControlEventTouchUpInside];
        funNameBtn.titleLabel.font=[UIFont systemFontOfSize:contenfot];
        funNameBtn.contentHorizontalAlignment=UIControlContentHorizontalAlignmentLeft;
        [self addSubview:funNameBtn];
        
        
    }
//     [[Global getJudgeTheErrorStr:[model.dict objectForKey:@"question"]]isEqualToString:@""]
    if ([model.dict objectForKey:@"question"]==NULL|| [[Global getJudgeTheErrorStr:[model.dict objectForKey:@"question"]]isEqualToString:@""]) {
        
    }else{
    
        UIImageView*wenhaoImage=[[UIImageView alloc]initWithFrame:CGRectMake(15, 416, 32/2, 32/2)];
        wenhaoImage.image=[UIImage imageNamed:@"wenhao"];
        [self addSubview:wenhaoImage];
        UILabel*question=[[UILabel alloc]initWithFrame:CGRectMake(35, 400, ScreenWidth, 50)];
        question.text=[NSString stringWithFormat:@"%@",[model.dict objectForKey:@"question"]];
        question.font=[UIFont systemFontOfSize:15];
        question.textColor=luseColor;
        [self addSubview:question];

    }
    
    UILabel*line=[[UILabel alloc] initWithFrame:CGRectMake(10, 450, ScreenWidth-20, 0.45)];
    [line setBackgroundColor:[UIColor colorWithRed:238.0f/255.0f green:238.0f/255.0f blue:238.0f/255.0f alpha:1.0f]];
    [self addSubview:line];

    _heightView.frame=CGRectMake(0, 451, ScreenWidth, 0.15);
        
    
}

-(void)createView
{
    self.serialNumber=[[UILabel alloc] init];
    self.serialNumber.font= [UIFont systemFontOfSize:13];
    self.serialNumber.text=@"编号 ";
    self.serialNumber.textAlignment=NSTextAlignmentCenter;
    [self.serialNumber.layer setCornerRadius:2];
    [self.serialNumber.layer setBorderWidth:0.5];
    CGColorSpaceRef tureBTnSpace = CGColorSpaceCreateDeviceRGB();
    CGColorRef tureBTncolorref = CGColorCreate(tureBTnSpace,(CGFloat[]){228/255.0, 228/255.0, 228/255.0, 1.0});
    [self.serialNumber.layer setBorderColor:tureBTncolorref];//边框颜色
    self.serialNumber.textColor=[UIColor whiteColor];
    self.serialNumber.backgroundColor=luseColor;
    self.serialNumber.layer.masksToBounds = YES;
    [self addSubview:self.serialNumber];
    
    self.reportNo=[[UILabel alloc] init];
    self.reportNo.font= [UIFont systemFontOfSize:16];
    self.reportNo.textColor=[UIColor colorWithRed:51/255.0f green:51/255.0f blue:51/255.0f alpha:1.0];
    [self addSubview:self.reportNo];
    
    
    self.reportDateName=[[UILabel alloc] init];
    self.reportDateName.font= [UIFont systemFontOfSize:14];
    self.reportDateName.text=@"检测时间";
    self.reportDateName.textColor=zhonghuiColor;
    [self addSubview:self.reportDateName];
    self.reportDate=[[UILabel alloc] init];
    self.reportDate.font= [UIFont systemFontOfSize:14];
    self.reportDate.textColor=shenhuiColor;
    [self addSubview:self.reportDate];
    self.address=[[UILabel alloc] init];
    self.address.font= [UIFont systemFontOfSize:14];
    self.address.text=@"检测地点";
    self.address.textColor=zhonghuiColor;
    [self addSubview:self.address];
    
    self.companyName=[[UILabel alloc] init];
    self.companyName.font= [UIFont systemFontOfSize:14];
    self.companyName.textColor=shenhuiColor;
    [self addSubview:self.companyName];
    
    self.lineLabel=[[UILabel alloc] initWithFrame:CGRectMake(10, 105, ScreenWidth-20, 0.45)];
    [self.lineLabel setBackgroundColor:[UIColor colorWithRed:238.0f/255.0f green:238.0f/255.0f blue:238.0f/255.0f alpha:1.0f]];
    self.lineLabel.textColor=[UIColor clearColor];
    [self addSubview:self.lineLabel];
    
    
    
    self.inspectionRecords=[[UILabel alloc] init];
    self.inspectionRecords.font= [UIFont systemFontOfSize:15];
    self.inspectionRecords.text=@"检测记录";
    self.inspectionRecords.textColor=qianheiColor;
    [self addSubview:self.inspectionRecords];

   
    
    _heightView=[[UIView alloc]init];
    _heightView.backgroundColor=qianhuiColor;
    [self addSubview:_heightView];
    

}


-(void)setViewAutoLayout
{
    
    [self.serialNumber mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left).with.offset(15) ;
        make.height.equalTo(@15);
        make.top.equalTo(self.mas_top).with.offset(25);
    }];
    [self.reportNo mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.serialNumber.mas_right).with.offset(5);
        
        make.centerY.equalTo(self.serialNumber.mas_centerY) ;
    }];
    
    [self.reportDateName mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left).with.offset(15) ;
        make.top.equalTo(self.mas_top).with.offset(50);
    }];
    
    [self.reportDate mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.reportDateName.mas_right).with.offset(5);
        make.centerY.equalTo(self.reportDateName.mas_centerY) ;
    }];
    
    [self.address mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self.mas_left).with.offset(15) ;
        make.top.equalTo(self.mas_top).with.offset(67);
    }];
    [self.companyName mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.address.mas_right).with.offset(5);
        make.centerY.equalTo(self.address.mas_centerY) ;
    }];
    [self.inspectionRecords mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left).with.offset(15) ;

        make.top.equalTo(self.mas_top).with.offset(120);
    }];

    
}


@end
